package com.tjn.generic.GenericExercise02;

import java.util.ArrayList;
import java.util.Comparator;

/**
 * @author 陶镓妮
 * @version 1.0
 */
@SuppressWarnings("all")
public class GenericExercise02 {
    public static void main(String[] args) {
        ArrayList<Employee> employees = new ArrayList<>();
        employees.add(new Employee("tjn",20000,new MyDate(2005,5,9)));
        employees.add(new Employee("dy",30000,new MyDate(2003,3,2)));
        employees.add(new Employee("dy",40000,new MyDate(2003,6,8)));

        System.out.println(employees);
        employees.sort(new Comparator<Employee>() {
            @Override
            public int compare(Employee o1, Employee o2) {
                int i = o1.getName().compareTo(o2.getName());
                if(i != 0){
                    return i;
                }
                return o1.getBirthday().compareTo(o2.getBirthday());
            }
        });
        System.out.println(employees);
    }
}


